<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>品牌馆_建筑安装行业知名品牌_安装通</title> 
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" />
<meta name="description" content="安装通品牌馆包含各种产品的知名品牌商家，能够保证产品质量，让您放心采购，不用担心产品质量问题。">
<meta name="keywords" content="安装通品牌馆,建筑安装行业知名品牌,安装通">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
    <link href="/res/css/common/baseAzt.css" rel="stylesheet" type="text/css"/>
    <link href="/res/css/respective/brand/brand.css" rel="stylesheet" type="text/css"/>
     <link href="/res/css/mall/mallIndex.css" rel="stylesheet">
    <link href="/res/css/baoPin/baoPin.css" rel="stylesheet">
</head>
<body>
	[#include "/front/common/front_headMal.html"]
	<img style="width: 100%;" alt="" src="/res/images/respective/brand/brand_02.jpg"/>
	<div class="w1200" style="margin-top: 20px;">
		<div class="brandOuter">
			<div id="searchItem">
				<strong class="bigTitle">集采品牌汇&nbsp;&nbsp;&nbsp;</strong>
				<em>已选条件：</em>
				<div class="chosed tj">

				</div> 
			</div>
			<hr>
			<div class="rot" id="categorySearch">
				<label>产品分类：</label>
				<b class="duoChose" onclick="multi()">多选+</b>
				<div class="chosed sigle" data-name="categorySId">
					[#list categoryList as category]
						<dfn data-value="${category.id!}">${category.name!}</dfn>
					[/#list]
				</div>
			</div>
		</div>
		
		<p class="navSec">
			<em>搜索到 <span id="total"></span>个相关品牌</em>
		</p>
		
		<div id="dataTbody">
		</div>
		<div id="page">
		</div>
	</div>
	[#include "/front/common/front_foot.html"]
</body>

	<!-- 数据展示模板 -->
	<script type="text/html" id="dataTemplate">
		{{# $.each(d.data, function(n, list) { }}
        <ul class="brandPics">
			{{# $.each(list, function(i, v) { }} 
            <li style="position: relative;" onclick="window.open('{{v.urlPath}}')">
					<p>
						<img alt="{{v.brandName}}" src="{{v.productImg||'/res/images/respective/brand/brand_02.jpg'}}">
					</p> 
					<div class="logo">
						<div>
							<img alt="{{v.brandName}}" src="{{v.logo||'/res/images/respective/brand/brand_02.jpg'}}">
							<h3 style="text-align:center">{{v.brandName}}</h3>
						</div>
					</div>  
					<h4>{{v.companyName}}</h4>
            </li>
			{{# if(i != list.length - 1) { }}
			<!-- 最后一个不加li -->
			<li class="navBar"></li>
			{{# } }}
			{{# }) }}
        </ul>
		{{# }) }}
	</script>


<!-- 搜索项目 -->
<script type="text/html" id="searchItemTemplate">
	<em class="tiaoJian" data-name="{{d.name}}" data-value="{{d.value}}">{{d.text}}<i onclick='removeItem(this)'></i></em>
</script>
<script src="/res/js/common/jquery.1.9.1.min.js"></script>
<script type="text/javascript" src="/res/third/layer/layer.js"></script>
<script type="text/javascript" src="/res/third/laytpl/laytpl.js"></script>
<script type="text/javascript" src="/res/third/laypage/laypage.js"></script>
<script type="text/javascript" src="/res/third/laydate/laydate.js"></script>
<script src="/res/js/common/jquery.ellipsis.js"></script>
<script type="text/javascript">
	var pageNo = 1;		//当前页码
	var showSize = 4;	//每行显示数量
	var rowSize = 4;	//每页显示行数
	laypage.dir = '/res/third/laypage/skin/aztpage.css';
	$(function(){ 
		search();
		//绑定单选点击事件
        $('.brandOuter .rot').on('click', '.sigle dfn', function() {
        	if($(".rot").hasClass("manyBord")){
        		return;
        	}
        	$("#categorySearch").hide();
			var name = $(this).parent().attr('data-name');
			var value = $(this).attr('data-value');
        	
        	addSearchItem(name, value, $(this).text().trim());
        	pageNo = 1;
        	search();
		}); 

		//绑定多选点击事件
        $(".brandOuter .rot").on("click", ".sigle dfn",function(){
        	if(!$(".rot").hasClass("manyBord")){
        		return;
        	}
        	$(this).addClass("chosedfn");
            $(this).find("b").remove(); 
            var x='<b style="border:none;"><i style="background-position:0 0;" onclick="cacleMany(this)"></i></b>';
            $(this).append(x);
            $(this).parents(".manyBord").find(".diaCof").removeClass("diaCof");
            return false;
        });
		 
	}); 
	
	function addSearchItem(name, value, text) {
		if($(".chosed.tj").find("em").length == 0) {
	        var clearAll = '<em class="tiaoJian clearAl" onclick="clearAll()">清空筛选条件</em>';
	        $("#searchItem").append(clearAll);
		}
		
        var searchItem = laytpl($('#searchItemTemplate').html()).render({name : name, value : value, text : text});
        $("#searchItem .tj").append(searchItem);
        
	}

	 /*移除搜索项**/
    function removeItem(obj) {
        $(obj).parents('em:eq(0)').remove();
		if($(".chosed.tj").find("em").length == 0) {
			$(".tiaoJian.clearAl").remove();
	    	$("#buttons").remove();
			$("#categorySearch").show();
		}
        pageNo = 1;
		search();
	}
	
	/*单击多选**/
	function multi(){    
		$(".duoChose").hide();
		$(".rot").addClass("manyBord");
		var b='<div id="buttons" style="text-align:center;margin-top: 10px;"><button type="button" onclick="confirmMulti(this)" class="confirmLink queRen diaCof" style="margin-right:20px;">确认</button><button type="button" class="confirmLink" onclick="canCel(this)">取消</button></div>';
		$(".rot").append(b);
	} 
	
	/**
	 * 多选-确认
	 * */
	function confirmMulti(obj) {
		if($(obj).hasClass('diaCof')) {
			return;
		}
		var name = $(this).parent().attr('data-name');
		var value = '';
		var text = '';
		$.each($('dfn.chosedfn'), function() {
			addSearchItem(name, $(this).attr('data-value') , $(this).text());
		});
		/*$.each($('dfn.chosedfn'), function() {
			value += $(this).attr('data-value') + ',';
			text += $(this).text().trim() + '-';
		});
		if(value != '') {
			value = value.substring(0, value.length - 1);
            text = text.substring(0, text.length - 1);
		}
        addSearchItem(name, value, text);*/
        $("#categorySearch").hide();
        canCel(obj);
		pageNo = 1;
		search();
	}
	
	/*取消多选中的单个**/
	function cacleMany(obj){
		var $container = $(obj).parents('.rot.manyBord');
        $(obj).parents('dfn').removeClass('chosedfn');
        $(obj).parents('dfn').find('b').remove();
		if($container.find('dfn.chosedfn').length == 0) {
			$container.find('button.queRen').addClass('diaCof');
		} 
	}
	
	/*清空条件**/
	function clearAll(){
		$("#buttons").remove();
		$(".chosed.tj").find("em").remove();
		$(".tiaoJian.clearAl").remove();
		$("#categorySearch").show();
		pageNo = 1;
		search();
	}
	/*取消多选**/
	function canCel(o){
		$("#buttons").remove();
		$(".rot").removeClass("manyBord");
		$(".duoChose").show();
		
		$.each($(".chosed.sigle").find('dfn.chosedfn'), function() {
			$(this).removeClass('chosedfn');
			$(this).find('b').remove();
		});
	}
	
	function search() {
		var param = 'pageNo=' + pageNo + '&showSize=' + showSize + '&rowSize=' + rowSize ;
		if($(".chosed.tj .tiaoJian").length > 0){
			var categorySId = '';
			$.each($('.chosed.tj .tiaoJian'), function() {
				categorySId += $(this).attr('data-value') + ",";
			})
			categorySId = categorySId.substring(0, categorySId.length - 1);
			param+= '&categorySId=' + categorySId;
		}
		$.ajax({
		    url : '/brand/searchBrand',
		    type : 'post',
		    dataType : 'json',
			data : param,
		    beforeSend : function() {
		        layer.load(2, {shade: 0.1});
		    },
		    success : function(res) {
		        if(res && res.success) {
		            var html = laytpl($('#dataTemplate').html()).render({ data : res.attributes.data});
					$('#dataTbody').html(html);
					$('#total').html(res.attributes.total);

		            //显示分页
		            laypage({
		                cont: 'page',
		                pages: res.attributes.pages,
						first : 1,
						last : res.attributes.pages,
		                curr: pageNo, //当前页
		                jump: function(obj, first) {
		                    if(!first) {
		                        pageNo = obj.curr;
		                        search(pageNo);
		                    }
		                }
		            });	
		        }
		    },
		    complete : function() {
		        layer.closeAll('loading');
		    }
		})
	}
</script>
</html>